Module Factions

Tuple Documentation of module_factions.py
Each faction record contains the following fields:
1) Faction id: used for referencing factions in other files.
    The prefix fac_ is automatically added before each faction id.
2) Faction name.
3) Faction flags. See header_factions.py for a list of available flags
4) Faction coherence. Relation between members of this faction.
5) Relations. This is a list of relation records.
    Each relation record is a tuple that contains the following fields:
   5.1) Faction. Which other faction this relation is referring to
   5.2) Value: Relation value between the two factions.
          Values range between -1 and 1.
6) Ranks
7) Faction color (default is gray)

module_factions.py contains all the factions used by the module system and by M&B's artificial intelligence. Though a small file, it governs several important settings which we will cover here.

The file immediately begins with a Python list: factions = [
As in most of the module files, the first few tuples are hardwired into the game and should not be edited. If you scroll down just a bit, you will find the "deserters" tuple as an example of a faction:

								
									("deserters","Deserters", 0, 0.5,[("manhunters",-0.6),("merchants",-0.5),("player_faction",-0.1)], [], 0x888888),
								
							

This is a short, simple tuple. It governs the "deserters" faction, whose major enemies are the "manhunters", "merchants", and "player_faction" factions. If a faction's relation with "deserters" is not defined anywhere in module_constants, it will automatically be set to 0, hence the two factions will be absolutely neutral to each other.
"deserters" tuple examination:

								
									1) Faction id = "deserters"
2) Faction name = "deserters"
3) Faction flags = 0
4) Faction coherence = 0.5
5) Inter-faction relations:
   5.1) Faction = "manhunters", "merchants", "player_faction"
   5.2) Relation = -0.6, -0.5, -0.1
6) no Rank is listed
7) the color of this faction is set the to the hex value of 0x888888 (Just like with strings, only the last 6 digits are the RGB values)

This faction has no flags, a neutral faction coherence, and three enemies defined in its tuple. However, if we look elsewhere, we can find that (for example) all "kingdom_#"s have a relation of -0.02 with "deserters", as defined in any of the kingdom tuples (such as "kingdom_1", the "Kingdom of Swadia"). This is because a relation works two ways - it only needs to be set once, and the value will count for both factions. In general, the value 0 means that the factions are at peace and a negative value means that those factions are at war. Positive numbers do not really matter with Native diplomacy.[1]

It should also be possible to declare a constant like default_kingdom_relations before the faction list is beginning in which some often used relationships are getting defined and which are then replacing some of the tuples.

Regarding field 6, "Ranks": It is a vestigial feature from the M&B versions 0.7xx and earlier - you could earn faction reputation from quests and earn stipends from being a retainer. Instead of being a vassal holding land and such, you used to get paid by advancing in ranks.[2] It is now deprecated and not getting used anymore.

Faction Flags

  • ff_always_hide_label: This flag is getting used by the "Innocents" and "Merchants" factions. It hides the faction name when hovering with the mouse over any party icon belonging to that faction in the 'popup tooltip'.

Difference between Faction and Culture

In Native you will discover at some point that there exist factions and cultures. The culture setup basically allows a kind of meta-faction to exist. For example, if the Kingdom of Swadia is wiped out, their culture (Swadian) still exists in their original villages and towns. The culture is not a kingdom - just a placeholder of sorts for the basic tier 1-5 troops, town walkers, etc..[3] A culture is thus basically just a reference to a specific troop tree since it is mostly used at the recruitment to define the type of recruits which depend on the culture of the village.

However, if you search for culture_1 at the files you will also find the script "get_culture_with_faction_for_music". This script assigns a music track to each faction, in our example to Kingdom 1, assigning the flag mtf_culture_1 which has been defined in header_music.py and been set up in module_music.py. At the world map and at the scenes the player hears at the respective locations the music tracks for this culture. Those flags represent a soft limit for the number of different cultures since you cannot define more than six. However, as long as you ignore the part with the music tracks[4] you can setup as many cultures as you want.

Changing Faction Relations [5]

The most direct method would be to use the operation set_relation but that doesn't taken into account the various political consequences. It is therefore recommended to look in module_scripts.py for its usage. Take note that when you change Faction A relation with Faction B to X, you are automaticly changing Faction B relation with Faction A to X too. The relation should be between 1 (friendly) and -1 (hateful) with 0 being neutral. Anything less than 0 will cause atacks with a value of -1 causing the most atacks.

Difference between Player's Faction and Player Supporters' Faction

The similar sounding constants fac_player_faction and fac_player_supporters_faction, and the variable $players_kingdom might be irritating at first sight. Latter one is a variable which will hold different values depending on the what the player is doing in the game. If a player is a vassal of a kingdom, "$players_kingdom" will hold the faction ID "fac_kingdom_X" value of that faction. The "fac_player_supporters_faction" is the actual faction that gets assigned to "$players_kingdom" and to the player's vassals if the player is a rebel or creates their own faction. The "fac_player_faction" tracks player-specific relations with other factions, etc.

Maximum Amount of Factions

There is a hard-coded limit of 128 factions, 0 to 127 (signed small int). You can't bypass the engine with Python hack.